#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define maxn 200200
using namespace std;
int le[maxn];
int rk[maxn];
int main()
{
	int n,m,q;
	while(scanf("%d %d %d",&n,&m,&q)!=EOF)
	{
		int x,y;
		int numli = n;
		int numra = m;
		memset(le,0,sizeof(le));
		memset(rk,0,sizeof(rk));
		for(int i = 1;i<=q;i++)
		{
			scanf("%d %d",&x,&y);
			if(!le[x])
			{
				le[x] = 1;
				numli--;
			} 
			if(!rk[y])
			{
				rk[y] = 1;
				numra--;
			} 
		}
		printf("%d\n",max(numli,numra));
	}
} 
